package com.squirrels.server.config;

import com.squirrels.server.utils.JWTUtils;
import com.squirrels.server.utils.SystemUtils;
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * 创建者: FlyingSquirrels
 * 创建时间: 2024/7/30 16:38
 * 描述: 服务配置
 */
@Configuration
public class ServerConfig {

    @Resource private MongoConfig mongoConfig;
    @Resource private NettyConfig nettyConfig;
    @Resource private JWTUtils jwtUtils;

    // 配置文件扫描路径
    public static final String configPath = "classpath:*.yml";
    // 连接处理类扫描路径
    public static final String workerPath = "classpath:com/squirrels/server/work/*.class";
    // 连接类包名
    public static final String workerPackage = "com.squirrels.server.work";

    // 开始启动
    public void start() throws InterruptedException {
        // 启动netty服务器
        nettyConfig.run();
        JWTUtils.jwtUtils = jwtUtils;
    }

    // 关闭项目
    public void stop(){
        nettyConfig.closeGroup();
        mongoConfig.stop();
    }
}
